package leetcode.力扣竞赛.第389场周赛;

/**
 * description:
 *
 * @author 颜真明
 * @date 2024/3/24  10:47
 */
public class Solution3084 {
    public static void main(String[] args) {
        System.out.println(countSubstrings("abada", 'a'));
        System.out.println(countSubstrings("zzz", 'z'));

    }
    public static long countSubstrings(String s, char c) {
        long count = 0L;
        long res = 0L;
        for (int i = 0; i < s.length(); i++) {
            if (c== s.charAt(i)) count++;
        }
        while (count > 0) {
            res += count--;
        }
        return res;
    }
}
